package com.hfh.homework;

import org.junit.Test;

import java.io.*;

/**
 * @Author hfh
 * @Date 2022 09 07 14 19
 **/
public class Work2 {
    @Test
    public void test1(){
        long time = System.currentTimeMillis();
        try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream("file/最后的人.mp4"));
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("file/two.mp4"))){
            byte[] arr = new byte[1024];
            int len;
            while ((len=bis.read(arr))!=-1){
                bos.write(arr,0,len);
                bos.flush();
            }
        }catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(System.currentTimeMillis() - time);
    }

    @Test
    public void test(){
        long time = System.currentTimeMillis();
        try(FileInputStream fis = new FileInputStream("file/最后的人.mp4");
            FileOutputStream fos = new FileOutputStream("file/one.mp4")){
            byte[] arr = new byte[1024];
            int len;
            while ((len=fis.read(arr))!=-1){
                fos.write(arr,0,len);
                fos.flush();
            }
        }catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(System.currentTimeMillis() - time);
    }
}